/*
 * @Author: chenxuan
 * @Date: 2022-07-07 15:41:44
 * @LastEditTime: 2023-01-06 15:37:46
 * @LastEditors: chenxuan
 */
const valiEmail = /^([a-zA-Z0-9]+[-_\.]?)+@[a-zA-Z0-9]+\.[a-zA-Z]+$/;
const validCode =  /^\w{2,32}$/;
const valiURL = /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/; //以http/https/ftp/ftps开头，可包含路径、携带参数!如http://xx.xx.xx/path?a=1
const valiPhone = /^(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])\d{8}$/;
const valiTel = /0\d{2,3}-\d{7,8}/;
const valiPort = /^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/;
const valiPersonName = /^(([a-zA-Z+\.?\·?a-zA-Z+]{2,30}$)|([\u4e00-\u9fa5+\·?\u4e00-\u9fa5+]{2,30}$))/ //大卫·波菲尔、王林  Mr.li
const valiName = /^[\u4E00-\u9FA5A-Za-z0-9_]{2,32}$/ //匹配中文、数组、英文、下划线,2-64位
const valiZh = /^[\u4e00-\u9fa5]{0,}$/ //校验中文
const valiEn = /^[A-Za-z]{2,32}$/ //校验英文
const valiPswd1 = /^.*(?=.{6,})(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*? ]).*$/ //强密码校验 最少6位，包括至少1个大写字母，1个小写字母，1个数字，1个特殊字符
const valiPswd2 = /^[a-zA-Z]\w{5,17}$/ //弱密码校验 长度在6~18之间，只能包含字母、数字和下划线
const valiPath = /^\/(\w+\/?){2,100}$/
const valiPath_ = /^([a-zA-z]:)?\/([a-zA-Z-_0-9\.]+\/)*$/
const valiIp = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
const valiIprange = /^(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))-(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))$/;
const valiInt = /^[0-9]\d*$/;
const valiNumLetter = /^\w{0,20}$/; //匹配数字和、字母、下划线组合，可以全是数字、字母、下划线


export default {
    valiEmail,
    validCode,
    valiURL,
    valiPhone,
    valiTel,
    valiPswd1,
    valiPswd2,
    valiPort,
    valiEn,
    valiZh,
    valiPersonName,
    valiName,
    valiPath,
    valiPath_,
    valiIp,
    valiIprange,
    valiInt,
    valiNumLetter
}
